package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.domain.Book;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface BookMapper {
    @Select("select * from book where book_status!='3' order by book_uploadtime desc")
    @Results(id = "bookMap",value = {
            @Result(id = true,column = "book_id",property = "id"),
            @Result(column = "book_name",property = "name"),
            @Result(column = "book_isbn",property = "isbn"),
            @Result(column = "book_press",property = "press"),
            @Result(column = "book_author",property = "author"),
            @Result(column = "book_pagination",property = "pagination"),
            @Result(column = "book_price",property = "price"),
            @Result(column = "uploadtime",property = "uploadTime"),
            @Result(column = "book_status",property = "status"),
            @Result(column = "book_borrower",property = "borrower"),
            @Result(column = "borrowtime",property = "borrowTime"),
            @Result(column = "returntime",property = "returnTime")
    })
    Page<java.awt.print.Book> selectBooks();
    @Select("select * from book where book_id = #{id};")
    Book findByid(String id);
    Integer editBook(Book book);
    @ResultMap("bookMap")//使用bookMap的结果集映射
    Page<Book> searchbook(Book book);//搜索图书
    Integer addbook(Book book);
    @ResultMap("bookMap")
    Page<Book> selectborrowed(Book book);
    @ResultMap("bookMap")
    Page<Book> selectmyborrowed(Book book);
}
